home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Linux
/
Kubuntu 8.10
/
kubuntu-8.10-desktop-i386.iso
/
casper
/
filesystem.squashfs
/
lib
/
partman
/
init.d
/
30parted
< prev
next >
Wrap
Text File
|
2008-10-29
|
3KB
|
141 lines
#!/bin/sh
set -e
. /lib/partman/lib/base.sh
. /usr/share/debconf/confmodule
ORIG_IFS="$IFS"
part_of_sataraid () {
local raiddev
for raiddev in $(dmraid -r -c); do
if [ "$(readlink -f $raiddev)" = $1 ]; then
return 0
fi
done
return 1
}
part_of_multipath() {
local mpdev
type multipath >/dev/null 2>&1 || return 1
if is_multipath_part $1; then
return 0
fi
# The block devices that make up the multipath:
# Output looks like \_ 4:0:0:1 sdc 8:32 ...
for mpdev in $(multipath -l | \
grep '_ \([#0-9]\+:\)\{3\}[#0-9]\+ [hs]d[a-z]\+ [0-9]\+:[0-9]\+' | \
cut -f4 -d' '); do
if [ "$(readlink -f /dev/$mpdev)" = $1 ]; then
return 0
fi
done
return 1
}
if [ ! -f /var/run/parted_server.pid ]; then
mkdir -p /var/run
parted_server
RET=$?
if [ $RET != 0 ]; then
# TODO: How do we signal we couldn't start parted_server properly?
exit $RET
fi
rm -rf /var/lib/partman/old_devices
if [ -d $DEVICES ]; then
mv $DEVICES /var/lib/partman/old_devices
fi
mkdir $DEVICES || true
# Exclude devices that have mounted partitions.
disks=
db_get partman/filter_mounted
if [ "$RET" != false ]; then
while read dev rest; do
# Taken from split_device() in grub-installer.
disk=
case $dev in
/dev/[vhs]d[a-z]*)
disk="$(echo "$dev" | sed 's,\(/dev/[a-z]\+\).*,\1,')"
;;
/dev/*/c*d*)
disk="$(echo "$dev" | sed 's,\(/dev/.*/c[0-9]\+d[0-9]\+\).*,\1,')"
;;
esac
if [ -z "$disk" ]; then
continue
fi
if [ -n "$disks" ]; then
disks="$disks\|$disk"
else
disks="$disk"
fi
done < /proc/mounts
fi
if [ "$disks" ]; then
disks="^\($disks\)"
else
disks="^$"
fi
IFS="$NL"
for partdev in $(parted_devices |
grep -v '^/dev/md' | grep -v "$disks" |
sed 's,^/dev/\(ide\|scsi\|[hs]d\),!/dev/\1,' |
sort |
sed 's,^!,,' ); do
IFS="$TAB"
set -- $partdev
IFS="$ORIG_IFS"
device=$1
size=$2
model=$3
# Skip devices that are part of a dmraid device
if type dmraid >/dev/null 2>&1; then
if part_of_sataraid $device && \
[ -f /var/lib/disk-detect/activate_dmraid ]; then
continue
fi
fi
# Skip devices that are part of a multipathed device
if part_of_multipath $device; then
continue
fi
dirname=$(echo $device | sed 's:/:=:g')
dev=$DEVICES/$dirname
if [ -d /var/lib/partman/old_devices/$dirname ]; then
mv /var/lib/partman/old_devices/$dirname $dev
else
mkdir $dev || continue
fi
printf "%s" "$device" >$dev/device
printf "%s" "$size" >$dev/size
printf "%s" "$model" >$dev/model
if type dmraid >/dev/null 2>&1; then
if dmraid -sa -c | grep $(basename $device); then
>$dev/sataraid
fi
fi
cd $dev
open_dialog OPEN "$(cat $dev/device)"
read_line response
close_dialog
if [ "$response" = failed ]; then
cd /
rm -rf $dev
fi
done
rm -rf /var/lib/partman/old_devices
fi